package net.lab1024.sa.base.module.support.wxsm.controller;

import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.module.support.operatelog.annotation.OperateLog;
import net.lab1024.sa.base.module.support.wxsm.domain.form.WxsmAddForm;
import net.lab1024.sa.base.module.support.wxsm.domain.form.WxsmQueryForm;
import net.lab1024.sa.base.module.support.wxsm.domain.form.WxsmUpdateForm;
import net.lab1024.sa.base.module.support.wxsm.domain.vo.WxsmVO;
import net.lab1024.sa.base.module.support.wxsm.service.WxsmService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 消息推送 Controller
 *
 * @Author chenyuqiang
 * @Date 2025-09-06 23:11:23
 * @Copyright 1
 */

@RestController
@Tag(name = "消息推送")
@OperateLog
public class WxsmController {

    @Resource
    private WxsmService wxsmService;

    @Operation(summary = "分页查询 @author chenyuqiang")
    @PostMapping("/wxsm/queryPage")
    @SaCheckPermission("wxsm:query")
    public ResponseDTO<PageResult<WxsmVO>> queryPage(@RequestBody @Valid WxsmQueryForm queryForm) {
        return ResponseDTO.ok(wxsmService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author chenyuqiang")
    @PostMapping("/wxsm/add")
    @SaCheckPermission("wxsm:add")
    public ResponseDTO<String> add(@RequestBody  WxsmAddForm addForm) {
        return wxsmService.add(addForm);
    }

    @Operation(summary = "更新 @author chenyuqiang")
    @PostMapping("/wxsm/update")
    @SaCheckPermission("wxsm:update")
    public ResponseDTO<String> update(@RequestBody WxsmUpdateForm updateForm) {
        return wxsmService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author chenyuqiang")
    @PostMapping("/wxsm/batchDelete")
    @SaCheckPermission("wxsm:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return wxsmService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author chenyuqiang")
    @GetMapping("/wxsm/delete/{id}")
    @SaCheckPermission("wxsm:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return wxsmService.delete(id);
    }
}
